#ifndef DYN_ROOTS_BISECTION_H
#define DYN_ROOTS_BISECTION_H

#include "../utilities/dyn_functor.h"
#include "dyn_roots.h"

/*! \brief Implements the bisection method
 * using a bracketed root.
 *
 * It has a linear local convergence, but
 * can never fail (unless there is no root in the
 * bracketed interval).
 */

class Bisection : public RootFinding
{
public:
    /*! The constructor specifies the function,
     * the starting point, the end point, the initial
     * scanning speed and the maximum number of iterations
     * to perform.
     */
    Bisection(Functor& func, double initial, double end, double scan, double tol, int Nmax);

    /*! @name Accessor functions.
     * We declare specific accessor functions for
     * the bisection method.
     */
    //@{
    Functor& getFunctor(){return function;}
    double getScanningSpeed() {return scanningSpeed;}
    double getEndPoint() {return endPoint;}

    void setFunctor(Functor& _func){function=_func;}
    void setScanningSpeed(double newScanningSpeed) {scanningSpeed = newScanningSpeed;}
    void setEndPoint(double newEndPoint) {endPoint = newEndPoint;}
    //@}

    /*! Re-declaration of solve() pure virtual function.*/
    virtual int solve();

protected:
    /*! @name Specialized member variables.
     * We declare additional variables
     * specific to the bisection method.
     */
    //@{
    Functor& function;
    double scanningSpeed;
    double endPoint;
    //@}

};

#endif // DYN_ROOTS_BISECTION_H
